<?php
/**
 * Dependency abstract source
 *
 * PHP version 5
 *
 * @category  W
 * @package   Services
 * @author    Olivier Hoareau <olivier@phppro.fr>
 * @copyright 2009 PHPPRO http://www.phppro.fr
 * @license   http://dev.phppro.fr/license PHPPRO
 * @version   SVN: $Id:$
 * @link      http://dev.phppro.fr/projects/wdependency
 */
require_once 'W/W.php';
require_once 'W/Dependency/Source/Interface.php';
/**
 * Dependency abstract source
 *
 * @category  W
 * @package   Services
 * @author    Olivier Hoareau <olivier@phppro.fr>
 * @copyright 2009 PHPPRO http://www.phppro.fr
 * @license   http://dev.phppro.fr/license PHPPRO
 * @version   SVN: $Id$
 * @link      http://dev.phppro.fr/projects/wdependency
 */
abstract class W_Dependency_Source_Abstract implements W_Dependency_Source_Interface
{
    /**
     * Constructs a new source
     *
     * @return W_Dependency_Source_Interface
     */
    public function __construct ()
    {
    }
    public function configure($options=null)
    {
        if (false === is_array($options)) {
            $options = array();
        }
        foreach($options as $key=>$value) {
            $method = 'set'.ucfirst($key);
            if (false === method_exists($this,$method)) {
                throw new RuntimeException("Parameter '$key' not supported for source ".(string)$this);
            }
            $this->$method($value);
        }
        return $this;
    }
    public function __toString()
    {
        return get_class($this);
    }
}